package sfsoftware.util.graphics;


public class Sprite {
	private int x;
	private int y;
	protected String tex;	
	private int srcX;
	private int srcY;
	
	protected int height = 0;
	protected int width = 0;
	
	public Sprite(int destX, int destY, String texture)
	{
		x = destX;
		y = destY;
		tex = texture;
		srcX = 0;
		srcY = 0;
	}

	public Sprite(int destX, int destY, String texture, int destSrcX, int destSrcY)
	{
		x = destX;
		y = destY;
		tex = texture;
		srcX = destSrcX;
		srcY = destSrcY;
	}	
	
	public void draw(int width, int height)
	{
		draw(width, height, srcX, srcY, width, height);
	}
	
	// Only use this for non-scaled sprites. Assumes the source dimensions are the same as the destination ones.
	public void draw(int width, int height, int srcX, int srcY)
	{
		draw(width, height, srcX, srcY, width, height);
	}
	
	public void draw(int width, int height, int srcX, int srcY, int srcWidth, int srcHeight)
	{
		Graphics.drawSprite(this.getX(), this.getY(), tex, width, height, srcX, srcY, srcWidth, srcHeight);	
	}
	
	public void draw(int width, int height, int srcX, int srcY, int srcWidth, int srcHeight, float red, float green, float blue, float alpha)
	{
		Graphics.drawSprite(this.getX(), this.getY(), tex, width, height, srcX, srcY, srcWidth, srcHeight, red, green, blue, alpha);	
	}
	
	public void move(float destX, float destY)
	{
		move((int) Math.round(destX), (int) Math.round(destY));
	}
	
	public void move(int destX, int destY)
	{
		x = destX;
		y = destY;
	}
	
	public String getTexture()
	{
		return tex;
	}
	
	public int getHeight()
	{
		return height;
	}
	
	public int getWidth()
	{
		return width;
	}
	
	public float getX()
	{
		return (float) x;
	}
	public float getY()
	{
		return (float) y;
	}
	public int getSrcX()
	{
		return srcX;
	}
	public int getSrcY()
	{
		return srcY;
	}	
	public void setSrcX(int sourceX)
	{
		srcX = sourceX;
	}
	public void setSrcY(int sourceY)
	{
		srcY = sourceY;
	}
	public void setSrc(int sourceX, int sourceY)
	{
		srcX = sourceX;
		srcY = sourceY;
	}	
	public void setX(int destX)
	{
		x = destX;
	}
	public void setY(int destY)
	{
		y = destY;
	}
	public void setTexture(String newTex)
	{
		tex = newTex;
	}
}
